vui.Namespace('View.page2.Page', function () {
    var _this = this;
    _this.Init = function () {
        vui.Page.Init({
            componentList: ['antdComponents', 'HeaderBox', 'LeftMenu', 'TableList', 'UploadFiles', 'UploadImages', {
                id: 'Page',
                isPage: true,
                baseDir:'/demo/'
            }],
            fn: function () {
                _bindData();
            }
        })
    };

    var pageData = {
        table1: {
            title: '渠道客户报表',
            columns: [{
                fixed: 'left',
                title: '',
                dataIndex: 'Area',
                key: 'Area',
                align: 'left',
                width: 300,
            }, {
                title: '报备',
                dataIndex: 'baobeiCount',
                key: 'baobeiCount',
                width: 100,
                align: 'center',
            }, {
                title: '到访',
                dataIndex: 'daofangCount',
                key: 'daofangCount',
                width: 80,
                align: 'center',
            }, {
                title: '认筹',
                dataIndex: 'BookingCount',
                key: 'BookingCount',
                width: 80,
                align: 'center',
            }, {
                title: '认购套数',
                dataIndex: 'OrderCount',
                key: 'OrderCount',
                width: 80,
                align: 'center',
            }, {
                title: '认购金额(元)',
                dataIndex: 'OrderAmount',
                key: 'OrderAmount',
                align: 'right',
            }, {
                title: '签约套数',
                dataIndex: 'ContractCount',
                key: 'ContractCount',
                align: 'center',
                width: 80,
            }, {
                title: '签约金额(元)',
                dataIndex: 'ContractAmount',
                key: 'ContractAmount',
                align: 'right',
            }, {
                title: '退筹',
                dataIndex: 'BookingCancelCount',
                key: 'BookingCancelCount',
                width: 80,
                align: 'center',
            }, {
                fixed: 'right',
                title: '退房',
                dataIndex: 'OrderCancelCount',
                key: 'OrderCancelCount',
                width: 80,
                align: 'center',
            }],
            dataSource: [
                {
                    "Area": "地产板块",
                    "City": "",
                    "project": "",
                    "baobeiCount": "1",
                    "daofangCount": "1",
                    "BookingCount": "0",
                    "BookingCancelCount": "0",
                    "OrderCount": "0",
                    "OrderAmount": "0.00",
                    "OrderCancelCount": "0",
                    "ContractCount": "0",
                    "ContractAmount": "0.00",
                    "haschildren": "BFD658A5-F645-468C-A11C-FB1689C1A166",
                    "level": "5",
                    "key": "BFD658A5-F645-468C-A11C-FB1689C1A166",
                    "children": [{
                        "Area": "深圳区域",
                        "City": "",
                        "project": "",
                        "baobeiCount": "1",
                        "daofangCount": "1",
                        "BookingCount": "0",
                        "BookingCancelCount": "0",
                        "OrderCount": "0",
                        "OrderAmount": "0.00",
                        "OrderCancelCount": "0",
                        "ContractCount": "0",
                        "ContractAmount": "0.00",
                        "haschildren": "5B84A0F8-25D6-42C4-B91E-9E6723F2B87A",
                        "level": "6",
                        "key": "5B84A0F8-25D6-42C4-B91E-9E6723F2B87A",
                        "children": [{
                            "Area": "佛山地产",
                            "Column1": "",
                            "project": "",
                            "baobeiCount": "0",
                            "daofangCount": "0",
                            "BookingCount": "0",
                            "BookingCancelCount": "0",
                            "OrderCount": "0",
                            "OrderAmount": "0.00",
                            "OrderCancelCount": "0",
                            "ContractCount": "0",
                            "ContractAmount": "0.00",
                            "haschildren": "688184A3-51FA-493F-B677-D64C6DCACB1E",
                            "level": "7",
                            "key": "688184A3-51FA-493F-B677-D64C6DCACB1E",
                            "children": [{
                                "Area": "佛山院子",
                                "Column1": "",
                                "Column2": "",
                                "baobeiCount": "0",
                                "daofangCount": "0",
                                "BookingCount": "0",
                                "BookingCancelCount": "0",
                                "OrderCount": "0",
                                "OrderAmount": "0.00",
                                "OrderCancelCount": "0",
                                "ContractCount": "0",
                                "ContractAmount": "0.00",
                                "haschildren": "2AF0F1E0-558A-E711-80C7-00505686C900",
                                "level": "8",
                                "key": "2AF0F1E0-558A-E711-80C7-00505686C900",
                                "children": []
                            }]
                        }, {
                            "Area": "深圳地产",
                            "Column1": "",
                            "project": "",
                            "baobeiCount": "0",
                            "daofangCount": "0",
                            "BookingCount": "0",
                            "BookingCancelCount": "0",
                            "OrderCount": "0",
                            "OrderAmount": "0.00",
                            "OrderCancelCount": "0",
                            "ContractCount": "0",
                            "ContractAmount": "0.00",
                            "haschildren": "8E6A158D-B466-415F-8136-DF71CC789422",
                            "level": "7",
                            "key": "8E6A158D-B466-415F-8136-DF71CC789422",
                            "children": []
                        }, {
                            "Area": "西部地产",
                            "Column1": "",
                            "project": "",
                            "baobeiCount": "1",
                            "daofangCount": "1",
                            "BookingCount": "0",
                            "BookingCancelCount": "0",
                            "OrderCount": "0",
                            "OrderAmount": "0.00",
                            "OrderCancelCount": "0",
                            "ContractCount": "0",
                            "ContractAmount": "0.00",
                            "haschildren": "456A7A63-1550-47BA-BF12-2B16FA243E35",
                            "level": "7",
                            "key": "456A7A63-1550-47BA-BF12-2B16FA243E35",
                            "children": []
                        }]
                    }, {
                        "Area": "福州区域",
                        "City": "",
                        "project": "",
                        "baobeiCount": "0",
                        "daofangCount": "0",
                        "BookingCount": "0",
                        "BookingCancelCount": "0",
                        "OrderCount": "0",
                        "OrderAmount": "0.00",
                        "OrderCancelCount": "0",
                        "ContractCount": "0",
                        "ContractAmount": "0.00",
                        "haschildren": "6A329480-ED39-4CA9-BBF8-737281F15A5A",
                        "level": "6",
                        "key": "6A329480-ED39-4CA9-BBF8-737281F15A5A",
                        "children": []
                    }, {
                        "Area": "上海区域",
                        "City": "",
                        "project": "",
                        "baobeiCount": "0",
                        "daofangCount": "0",
                        "BookingCount": "0",
                        "BookingCancelCount": "0",
                        "OrderCount": "0",
                        "OrderAmount": "0.00",
                        "OrderCancelCount": "0",
                        "ContractCount": "0",
                        "ContractAmount": "0.00",
                        "haschildren": "77C03184-D6C3-405F-8C6B-29D53791E2B4",
                        "level": "6",
                        "key": "77C03184-D6C3-405F-8C6B-29D53791E2B4",
                        "children": []
                    }, {
                        "Area": "北京区域",
                        "City": "",
                        "project": "",
                        "baobeiCount": "0",
                        "daofangCount": "0",
                        "BookingCount": "0",
                        "BookingCancelCount": "0",
                        "OrderCount": "0",
                        "OrderAmount": "0.00",
                        "OrderCancelCount": "0",
                        "ContractCount": "0",
                        "ContractAmount": "0.00",
                        "haschildren": "B954F1F2-7B3C-49EF-95A2-428842860EFE",
                        "level": "6",
                        "key": "B954F1F2-7B3C-49EF-95A2-428842860EFE",
                        "children": []
                    }, {
                        "Area": "福州商业地产",
                        "City": "",
                        "project": "",
                        "baobeiCount": "0",
                        "daofangCount": "0",
                        "BookingCount": "0",
                        "BookingCancelCount": "0",
                        "OrderCount": "0",
                        "OrderAmount": "0.00",
                        "OrderCancelCount": "0",
                        "ContractCount": "0",
                        "ContractAmount": "0.00",
                        "haschildren": "E86188D8-714F-4212-816F-BA286B11F488",
                        "level": "6",
                        "key": "E86188D8-714F-4212-816F-BA286B11F488",
                        "children": []
                    }]
                }],
            loading: true,
        },
    };
    var param = {
        pageNo:1,
        pageSize:10,
    }
    //初始化本地数据
    var _bindData = function () {
        vui.Page.Render({
            id: ".app",
            componentID: "Page",
            isPage: true,
            template: '<Page />',
            data: pageData,
        });
        vui.Component.Page.setState(pageData);
        vui.Catch = {
            callBack: function (page, pageSize) {

                data.PageIndex = page;
                data.PageSize = pageSize;

                vui.Data.getFuncData({
                    funcid: "CustomerList_Select",
                    param: data,
                    success: function (res) {
                        pageData.table1.dataSource = res.data.List ? res.data.List : [];
                        pageData.table1.pagination.defaultCurrent = page;
                        pageData.table1.pagination.total = res.data.AllCount ? res.data.AllCount : 0;
                        pageData.table1.pagination.defaultPageSize = pageSize;
                        vui.Component.Page.setState(pageData);

                    }
                });
            },
            clear:function(){
                vui.Component.Page.setState(pageData);
            },
            checkChange:function(checked){
                pageData.table1.loading = checked;
                vui.Component.Page.setState(pageData);
            }
        };


    // vui.Data.getFuncData({
    //      funcid: "browseSysRole",
    //      param: {},
    //      success: function (res) {
    //          pageData.table1.dataSource = res.data.List ? res.data.List : [];
    //          pageData.table1.pagination.total = res.data.AllCount ? res.data.AllCount : 0;
    //          vui.Page.Render({
    //              id: ".app",
    //              componentID: "Page",
    //              isPage: true,
    //              template: '<Page />',
    //              data: pageData
    //          });
    //
    //      }
    //  });
         function getData(param){
             debugger
             // vui.Data.getFuncData({
             //     funcid: "browseSysRole",
             //     param: param,
             //     success: function (res) {
             //       debugger
             //     }
             // });
             vui.Data.getFuncData({
                 funcid: "browseUserRole",
                 param: {
                     userId:'1',
                 },
                 success: function (res) {
                   console.log('请求成功',res);
                 }
             });
             // $.ajax({
             //     type:'POST',
             //     url:'/api/role/browseSysRole',
             //     data:{},
             //     dataType:'text',
             //     success:function(res){
             //         debugger
             //     }
             // })
         }

        getData(param);

    };
});
